const colorList = ['#48DE00', '#F0BC00', '#D57300', '#B34230', '#5817B0', '#A91B1B']

// const comparison = {
//   so2: [0, 150, 500, 650, 800, 1600, '&infin;'],
//   no2: [0, 100, 200, 700, 1200, 2340, '&infin;'],
//   pm_10: [0, 50, 150, 250, 350, 420, '&infin;'],
//   co: [0, 5, 10, 35, 60, 90, '&infin;'],
//   o3: [0, 160, 200, 300, 400, 800, '&infin;'],
//   pm_2_5: [0, 35, 75, 115, 150, 250, '&infin;'],
//   vocs: [0, 1, 5, 10, 20, 50, '&infin;']
// }

export function getColorByValue(comparison, value, type) {
  if (!comparison[type]) return colorList[0]
  value = value * 1
  if (value >= comparison[type][0] && value <= comparison[type][1]) {
    return colorList[0]
  } else if (value > comparison[type][1] && value <= comparison[type][2]) {
    return colorList[1]
  } else if (value > comparison[type][2] && value <= comparison[type][3]) {
    return colorList[2]
  } else if (value > comparison[type][3] && value <= comparison[type][4]) {
    return colorList[3]
  } else if (value > comparison[type][4] && value <= comparison[type][5]) {
    return colorList[4]
  } else if (value > comparison[type][5]) {
    return colorList[5]
  } else {
    return colorList[0]
  }
}

export function getColorByRange(value, range) {
  value = value * 1
  if (value < range[1]) {
    return colorList[0]
  } else if (value >= range[1] && value < range[2]) {
    return colorList[1]
  } else if (value >= range[2] && value < range[3]) {
    return colorList[2]
  } else if (value >= range[3] && value < range[4]) {
    return colorList[3]
  } else if (value >= range[4] && value < range[5]) {
    return colorList[4]
  } else if (value >= range[5]) {
    return colorList[5]
  }
}
